<?php

require_once("View/View/PageView.php");
require_once("Homepage/View/HomepageView.php");
require_once("login/src/Model/LoginValidation.php");

class HomepageController
{
	/**
	*@var PageView
	**/
	private $pageView;
	/**
	*@var HomepageView
	**/
	private $homepageView;
	/**
	*@var Loginvalidation
	**/
	private $loginvalidation;

	public function __construct()
	{
		$this->pageView = new PageView();
		$this->homepageView = new HomepageView();
		$this->loginvalidation = new LoginValidation();
	}

	/**
	*@return Loginvalidation
	**/
	public function getHomepage()
	{
		$html = $this->homepageView->getHomepage();
		$html = $this->pageView->getHtmlPage("Home - Träningsdagboken", "", $html);
		return $html;
	}

	public function areWeLoggedIn()
	{
		if(!$this->loginvalidation->weAreLoggedIn())
		{
			header("Location:index.php");
		}
	}
}